﻿@using System.Security.Claims
@inherits LayoutComponentBase
@inject AuthenticationStateProvider AuthenticationStateProvider
@inject DialogService DialogService
@inject ToastService ToastService
@inject IDispatchService<string> DispatchService
@inject IAdminService IAdminService
@inject ILogger<MainLayout> nlogILogger;
@inject IHttpContextAccessor _httpContextAccessor

<BootstrapBlazorRoot>
    <ErrorLogger OnErrorHandleAsync="OnErrorHandleAsync">
        @* AutoRedirect 自动跳转  1时=3600000毫秒 *@
        <AutoRedirect Interval="3600000" RedirectUrl="/Login" IsForceLoad="true"></AutoRedirect>
        <Layout ShowGotoTop="true" ShowCollapseBar="true" ShowFooter="@ShowFooter" SideWidth="0"
                IsPage="true" IsFullSide="@IsFullSide" IsFixedHeader="@IsFixedHeader" IsFixedFooter="@IsFixedFooter"
                TabDefaultUrl="/" UseTabSet="@UseTabSet" AdditionalAssemblies="new[] { GetType().Assembly }"
                Menus="@Menus" class="@Theme">

            <Header>
                <span class="ms-3 flex-sm-fill d-none d-sm-block">Blazor 报表查询系统</span>
                <div class="flex-fill d-sm-none">
                </div>                                 
                <FullScreenButton TooltipText="点击切换全屏模式"></FullScreenButton>
                <AuthorizeView>
                    <AnnouncementDropdown CurrentUserId="@_userEntity!.Id" @key=@AnnouncementsKey></AnnouncementDropdown>
                    <Logout ImageUrl="images/Argo-C.png" DisplayName="@_userEntity?.NickName" UserName="@_userEntity?.UserName">
                        <LinkTemplate>
                            <a @onclick="ChangePassword"><i class="fa-solid fa-user"></i><span>更改密码</span></a>
                            <LogoutLink Url="/api/Account/Logout" />
                        </LinkTemplate>
                    </Logout>
                </AuthorizeView>
                <div class="layout-drawer" @onclick="@(e => IsOpen = !IsOpen)"><i class="fa fa-gears"></i></div>
            </Header>
            <NotAuthorized>
                <NotAuth></NotAuth>
            </NotAuthorized>
            <Side>
                <div class="layout-banner">
                    <img class="layout-logo" src="favicon.png" />
                    <div class="layout-title">
                        <span>报表导航</span>
                    </div>
                </div>
            </Side>
            <Main>
                <CascadingValue Value="this" IsFixed="true">
                    @Body
                </CascadingValue>
            </Main>
            <Footer>
                <div class="text-center flex-fill">
                    公司名称 &nbsp; 登录IP:@IP
                </div>
            </Footer>
            <NotFound>
                <NotFoundLayout></NotFoundLayout>
            </NotFound>
        </Layout>

        <Drawer Placement="Placement.Right" @bind-IsOpen="@IsOpen" IsBackdrop="true">
            <div class="layout-drawer-body">
                <div class="btn btn-info w-100" @onclick="@(e => IsOpen = false)">点击关闭</div>
                <GroupBox Title="布局调整">
                    <div class="row">
                        <div class="col-6">
                            <div class="layout-item @(IsFullSide ? "active d-flex" : "d-flex")" @onclick="@(e => IsFullSide = true)" data-toggle="tooltip" title="左右结构">
                                <div class="layout-left d-flex flex-column">
                                    <div class="layout-left-header"></div>
                                    <div class="layout-left-body flex-fill"></div>
                                </div>
                                <div class="layout-right d-flex flex-column flex-fill">
                                    <div class="layout-right-header"></div>
                                    <div class="layout-right-body flex-fill"></div>
                                    <div class="layout-right-footer"></div>
                                </div>
                            </div>
                        </div>
                        <div class="col-6">
                            <div class="layout-item flex-column @(IsFullSide ? "d-flex" : "active d-flex")" @onclick="@(e => IsFullSide = false)" data-toggle="tooltip" title="上下结构">
                                <div class="layout-top">
                                </div>
                                <div class="layout-body d-flex flex-fill">
                                    <div class="layout-left">
                                    </div>
                                    <div class="layout-right flex-fill">
                                    </div>
                                </div>
                                <div class="layout-right-footer">
                                </div>
                            </div>
                        </div>
                    </div>
                </GroupBox>

                <GroupBox Title="固定调整">
                    <div class="row">
                        <div class="col-6 d-flex align-items-center">
                            <Switch @bind-Value="@IsFixedHeader" OnColor="@Color.Success"></Switch>
                        </div>
                        <div class="col-6 text-right">
                            <span class="cell-label">固定页头</span>
                        </div>
                    </div>
                    <div class="row mt-3">
                        <div class="col-6 d-flex align-items-center">
                            <Switch @bind-Value="@IsFixedFooter" OnColor="@Color.Success"></Switch>
                        </div>
                        <div class="col-6 text-right">
                            <span class="cell-label">固定页脚</span>
                        </div>
                    </div>
                    <div class="row mt-3">
                        <div class="col-6 d-flex align-items-center">
                            <Switch @bind-Value="@ShowFooter" OnColor="@Color.Success"></Switch>
                        </div>
                        <div class="col-6 text-right">
                            <span class="cell-label">显示页脚</span>
                        </div>
                    </div>
                </GroupBox>

                <GroupBox Title="更多设置">
                    <div class="row">
                        <div class="col-6 d-flex align-items-center">
                            <Switch @bind-Value="@UseTabSet" OnColor="@Color.Success"></Switch>
                        </div>
                        <div class="col-6 text-right">
                            <span class="cell-label">@(UseTabSet ? "多标签" : "单页")</span>
                        </div>
                    </div>
                </GroupBox>
            </div>
        </Drawer>
    </ErrorLogger>
</BootstrapBlazorRoot>

<div id="blazor-error-ui">
    An unhandled error has occurred.
    <a href="" class="reload">Reload</a>
    <a class="dismiss">🗙</a>
</div>
